using System;
using System.Reflection;
namespace AppToolKit.Core.ObjectClone
{
	public class ProperyClone : ICloneMethod
	{
		private BindingFlags flags_;
		public ProperyClone(BindingFlags flags)
		{
			this.flags_ = flags;
		}
		public void Clone(ICloneObject o)
		{
			CloneObject cloneObject = (CloneObject)o;
			PropertyInfo[] properties = cloneObject.CloneType.GetProperties(this.flags_ | BindingFlags.Instance);
			CloneVisit cloneVisit = new CloneVisit();
			PropertyInfo[] array = properties;
			for (int i = 0; i < array.Length; i++)
			{
				PropertyInfo propertyInfo = array[i];
				object value = propertyInfo.GetValue(cloneObject.RightObject, null);
				object value2 = cloneVisit.Visit(value);
				Console.WriteLine(propertyInfo.Name);
				Console.WriteLine(value2);
				propertyInfo.SetValue(cloneObject.LeftOjbect, value2, null);
			}
		}
		public bool IsSuppor(ICloneObject o)
		{
			return o is CloneObject;
		}
	}
}
